//
//  UIImageToDataTransformer.m
//  PostMessa
//
//  Created by never down on 15-5-21.
//  Copyright (c) 2015年 ygy_ios. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import <UIKit/UIKit.h>
@implementation UIImageToDataTransformer :NSObject

+(BOOL)allowsReverseTransformation{
    //正反方向的转换都支持
    return YES;
}

+(Class)transformedValueClass{
    //输出是NSData格式
    return [NSData class];
}

-(id)transformedValue:(id)value{
    //属性－－－> 持久层数据库
    //Uiimage to nsdata
    return UIImagePNGRepresentation(value);
}

-(id)reverseTransformedValue:(id)value{
    //opposite to last
    return [[UIImage alloc]initWithData:value];
}

@end